﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MINERP.BLL.Statistics;
using FastReport;

namespace MINERP.Statistics.Forms
{
    public partial class FrmSalesmanCrushAndArrears : Form
    {
        Report reportShopCrushAndArrears = new Report();
        ShopCrushAndArrearsBLL bll = new ShopCrushAndArrearsBLL();
        public FrmSalesmanCrushAndArrears()
        {
            InitializeComponent();
        }


        private void FrmSalesmanCrushAndArrears_Load(object sender, EventArgs e)
        {
            LinkSalesman();
            dateEditStartTime.DateTime = DateTime.Now;
            dateEditEndTime.DateTime = DateTime.Now;
        }

        private void LinkSalesman()
        {
            SalesmanBLL sbll = new SalesmanBLL();
            cmbSalesman.Properties.DataSource = sbll.GetSalesmanList();
            cmbSalesman.Properties.DisplayMember = "SalesmanName";
            cmbSalesman.Properties.ValueMember = "SalesmanName";
            cmbSalesman.Refresh();
        }

        private void simpleButtonOk_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            simpleButtonOk.Enabled = false;
            if (string.IsNullOrEmpty(cmbSalesman.Text.Trim()))
            {
                MessageBox.Show("请选择业务员", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            try
            {
                reportShopCrushAndArrears.Preview = previewControl1;
                reportShopCrushAndArrears.RegisterData(bll.GetSalesmanCrushAndArrears(dateEditStartTime.DateTime, dateEditEndTime.DateTime,cmbSalesman.Text));

                reportShopCrushAndArrears.Load(Application.StartupPath + "\\Report\\业务员充值记录表.frx");
                reportShopCrushAndArrears.SetParameterValue("startTime", dateEditStartTime.DateTime);
                reportShopCrushAndArrears.SetParameterValue("endTime", dateEditEndTime.DateTime);
                previewControl1.Refresh();
                previewControl1.Show();
                reportShopCrushAndArrears.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
            finally
            {
                simpleButtonOk.Enabled = true;
                this.Cursor = Cursors.Default;
            }
        }

    }
}
